package com.example.demo.domain.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.example.demo.validations.ForCreate;
import com.example.demo.validations.ForUpdate;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import lombok.Getter;
import lombok.Setter;

/**
 * 分类实体类
 *
 * @author renliang
 */
@Getter
@Setter
@TableName("demo_category")
public class Category extends BaseEntity<Category> {
    /**
     * 主键
     */
    @NotNull(message = "主键ID不能为空", groups = ForUpdate.class)
    @TableId(type = IdType.ASSIGN_ID)
    @JsonSerialize(using = ToStringSerializer.class)
    private Long id;
    /**
     * 父节点
     */
    @NotNull(message = "父级节点ID不能为空", groups = ForCreate.class)
    @JsonSerialize(using = ToStringSerializer.class)
    private Long parentId;

    /**
     * 父级索引
     */
    private String ancestors;

    /**
     * 分类名称
     */
    @NotBlank(message = "节点名称不能为空")
    private String name;
    /**
     * 分类图标
     */
    private String icon;
    /**
     * 是否叶子节点
     */
    private Boolean isLeaf;

    /**
     * 排序号
     */
    private Integer sortNum;

    /**
     * 删除标志
     */
    private Boolean delFlag;
}